import  React  from  "react";
import "../css/input.css";
import  eventEmitter from   "../event";
var a=0;
class  input  extends  React.Component{
    constructor(props){
        super(props);
    }
    render() {
        return (
            <div className="box">
            <input type="text" placeholder="请输入留言内容" ref="input"/>
            <button onClick={()=>{
                a++;
                let  value=this.refs.input.value
                  if(value==""){
                    alert("输入内容不能为空！");
                    return ;
                  }
                  var  date =new  Date();
                  var  datestr=`${date.getFullYear()}年${date.getMonth()+1}月${date.getDate()}日${date.getHours()}时${date.getMinutes()}分`
                var   message={
                    content :value,
                    date:datestr,
                    a:a,
                }
                eventEmitter.emit("sendMessageTooBoard",message)
            }}>添加</button>
            </div>
        )
    }
}
export   default  input;